package org.vectrics.company.web.struts;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Category;
import org.apache.struts.action.ActionForm;
import org.vectrics.SystemException;
import org.vectrics.company.CompanyPerson;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.struts.Request;


public class ShowCompanyPersonEditAction extends RequestFormAction {
    private static Category log = Category.getInstance(ShowCompanyPersonEditAction.class);
	public static String JOB_PARAM = "job";

	
	protected String fillForm(ActionForm formIn, Request request, HttpServletResponse response) {
		String mapCode = "success";
		CompanyPersonForm form = (CompanyPersonForm)formIn;
		String companyIdParam = request.getParameter("companyPersonId");
		if (companyIdParam == null) {
			
		} else {
			CompanyPerson companyPerson = CoreServiceLocator.getCompanyService().findCompanyPerson(new Long(companyIdParam));
			if (companyPerson == null)
				throw new SystemException("Could not find company person: " + companyIdParam);
			form.setCompanyName(companyPerson.getCompany().getName());
			form.setPersonName(companyPerson.getPerson().getName());
		}
		return(mapCode);
	}

	protected ActionForm createForm() {
		ActionForm form = new CompanyPersonForm();
		return(form);
	}
	
}
